<?php

class PorderController extends CommonController{
	
	private $_model;
	
	public function __init(){
		$this->_model=K('Porder');
	}
	
	public function index(){
		
		if(!$_SESSION['uid'] || !$_SESSION['username']) go(U('Index/index'));
		$w=Q('get.w');
		switch ($w) {
			case 0:
			$data = K('Porder')->get_all_data(array('uid'=>$_SESSION['uid'],'status'=>0));
			
				break;
			case 1:
			$data = K('Porder')->get_all_data(array('uid'=>$_SESSION['uid'],'status'=>1));
				break;
			
			default:
			$data = K('Porder')->get_all_data(array('uid'=>$_SESSION['uid'],'status'=>0));
				break;
		}
		foreach ($data as $k => $v) {
				$data[$k]['oid']=K('OlistGoodView')->get_all_data(array('oid'=>$v['oid']));
				
			}
//		$a=array();
		foreach ($data as $k => $v) {
			foreach ($v['oid'] as $key => $value) {
				$data[$k]['oid'][$key]['option']=explode(',', $data[$k]['oid'][$key]['option']);
			}
		}
//		p($data);
		$this->assign('data',$data);
		$this->dis('Porder');
	}
	
	public function add(){
		
		$this->_model->add_data();
		$this->success('提交成功',U('Porder/index'));
	}
	
	public function del(){
		
		$this->_model->del_data(array('orderno'=>Q('get.orderno')));
		
		$this->success('订单取消成功');
	}
	
	
}






